package com.arpa.wms.mapper;

import com.arpa.wms.domain.dto.LocationDTO;
import com.arpa.wms.domain.entity.Location;
import com.arpa.wms.domain.vo.BatchRuleVO;
import com.arpa.wms.domain.vo.LocationVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 库位 Mapper 接口
 * </p>
 *
 * @author LEO
 * @since 2020-08-03
 */
public interface LocationMapper extends BaseMapper<Location> {

    /**
     * 查询列表
     * @param locationDTO
     * @return
     */
    List<LocationVO> queryList(LocationDTO locationDTO);

    List<LocationVO> queryByBearType(List<String> list);

    /**
     * 查询合计,包含总数
     * @param locationDTO
     * @return
     */
    LocationVO queryListSum(LocationDTO locationDTO);

    /**
     * 查询符合条件的库位数
     * @param locationDTO
     * @return
     */
    Integer queryLocationNum(LocationDTO locationDTO);

    /**
     * 更新状态
     * @param codes
     * @param status
     * @return
     */
    int changeStatus(String codes,String status,String deleteFlag);

     /**
      *  @author: Allen chen
      *  @Date: 2020/10/15 15:37
      *  @Description: 根据仓库code批量更新批示库位状态
      */
    int changeStatusByWarehouseCodes(@Param("list")List<String> list,@Param("status")String status,@Param("deleteFlag")String deleteFlag,@Param("groupCode")String groupCode);


    /**
     * 0库存的库区
     * @param codes
     * @return
     */
    List<String> emptyLocation(@Param("codes") List<String> codes,@Param("groupCode")String groupCode);
    /**
     *  @author: Allen chen
     *  @Date: 2020/10/10 9:15
     *  @Description: 根据code批量查询
     */
    List<LocationVO> getByCodes(@Param("list") List<String> list,@Param("groupCode")String groupCode);

    List<Location> getAll();

    Location getOne(String code);

    /**
     * 执行原生sql
     * @param sql
     * @return
     */
    int execSql(@Param("sql") String sql);

    BigDecimal localtionInventory(String code);


    /**
     * 获取仓库下所有有效库位，过滤掉临时库位、停用库位
     * @param warehouseCode 仓库标识
     * @return
     */
    List<Location> getAllEffectiveByWarehouseCode(String warehouseCode);


    /**
     * 获取所有库位
     * 根据实际情况增加
     * @param map 查询条件
     * @return
     */
    List<LocationVO> getAllByMap(Map<String,Object> map);


    LocationVO queryListSumLocation(Map<String, Object> map);
}
